from fastapi import APIRouter

from web.about import about
from web.contact_us import contact_us
from web.index import index
from web.news import news_list, news
from web.online_message import online_message
from web.product import product_list, product
from web.search import search

router = APIRouter(prefix="", tags=["api"])


def web_router():
    router.add_api_route(path="/", endpoint=index, methods=["GET"], name="index")
    router.add_api_route(path="/search", endpoint=search, methods=["GET"], name="search")
    router.add_api_route(path="/about/type/{page_type}", endpoint=about, methods=["GET"], name="about")
    router.add_api_route(path="/about/type/{page_type}/page/{page}", endpoint=about, methods=["GET"], name="about")
    router.add_api_route(path="/products", endpoint=product_list, methods=["GET"], name="all_product_list")
    router.add_api_route(path="/products/page/{page}", endpoint=product_list, methods=["GET"], name="all_product_list")
    router.add_api_route(path="/products/id/{id_}", endpoint=product_list, methods=["GET"], name="product_list")
    router.add_api_route(path="/products/id/{id_}/page/{page}", endpoint=product_list, methods=["GET"], name="product_list")
    router.add_api_route(path="/product/{id_}", endpoint=product, methods=["GET"], name="product")
    router.add_api_route(path="/news_items", endpoint=news_list, methods=["GET"], name="all_news_items")
    router.add_api_route(path="/news_items/page/{page}", endpoint=news_list, methods=["GET"], name="all_news_items")
    router.add_api_route(path="/news_items/id/{id_}", endpoint=news_list, methods=["GET"], name="news_items")
    router.add_api_route(path="/news_items/id/{id_}/page/{page}", endpoint=news_list, methods=["GET"], name="news_items")
    router.add_api_route(path="/news/id/{id_}", endpoint=news, methods=["GET"], name="news")
    router.add_api_route(path="/online_message", endpoint=online_message, methods=["GET"], name="online_message")
    router.add_api_route(path="/contact_us", endpoint=contact_us, methods=["GET"], name="contact_us")

    return router
